package  com.zhuiyun.imageserver.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @author: zcy
 * @date: 2023/3/10 10:29
 * @description: 配置类（配置拦截器、解决跨域）
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * @Author zcy
     * @Description 允许跨域
     * @Date 10:29 2023/3/10
     * @param registry
     * @Return void
     **/
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 允许跨域访问路径
        registry.addMapping("/**")
                // 允许跨域访问的源
                .allowedOrigins("*")
                // 允许请求方式
                .allowedMethods("POST","GET","PUT","DELETE","OPTIONS")
                // 预检间隔时间
                .maxAge(168000)
                // 允许头部设置
                .allowedHeaders("*");
    }
}
